package flst.ipiweb.struts.action.paiement;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import flst.ipiweb.service.ServicePaiement;
import flst.ipiweb.transverse.ModeDePaiement;

public class ListModePaiementAction extends Action{

	public ActionForward execute(
			ActionMapping mapping, 
			ActionForm form,
			HttpServletRequest request, 
			HttpServletResponse response)
			throws Exception {
		
			//On récupère la session
			HttpSession session = request.getSession();
			if(session.getAttribute("login") == null)
			{
				return mapping.findForward("login");
			}
		
			//Récupération de la liste des modes de paiement
			ServicePaiement sPaiement = new ServicePaiement();
			List<ModeDePaiement> listMode = sPaiement.listerModeDePaiement();
			request.setAttribute("listMode", listMode);
			
			
			//Titre de la page
			request.setAttribute("pageTitle", "paiement.list.title");
			//Activation de l'onglet paiement
			HashMap<String, String> onglet = new HashMap<String, String>();
			onglet.put("paiement", "active");
			request.setAttribute("onglet", onglet);

			return mapping.findForward("list_mode_paiement");
		}
}
